package com.game.number;

import java.util.ArrayList;
import java.util.List;

public class BoxUtil {
	
	public static Box2D generateRandomBox2D(String[] valSeq){
		List<Unit> units=new ArrayList<Unit>();
		int valLength=valSeq.length;
		int valWidth=Double.valueOf(Math.sqrt(valLength)).intValue();
		
		for(int x=1;x<=valWidth;x++){
			for(int y=1;y<=valWidth;y++){
				Unit unit=new Unit(x+","+y,valSeq[x+(y-1)*valWidth-1]);
				units.add(unit);
			}
		}
		
		return new Box2D(units);
	}
	
	public static void main(String[] args){
		String[] value=new String[]{"1","3","2","4","0","5","8","7","6"};
		String[] success=new String[]{"1","2","3","4","0","5","6","7","8"};
		
		Box2D box2d=BoxUtil.generateRandomBox2D(value);
		BoxPrinter printer=new BoxPrinter(2);
		printer.print(box2d);
	}
}
